<?php
defined('SEJUJOPEFDNGJSL') or exit('Access denied');

if($_POST['act']=='add'){
	$price = $_POST['price'];
	$highprice = $_POST['highprice'];
	$lowerprice = $_POST['lowerprice'];
	$openprice = $_POST['openprice'];
	$closeprice = $_POST['closeprice'];
    $msg = '';
	if ( $price < 0 || empty($price) ){
        echo "<script>var  msg = confirm('最新价格不能为小于0！');
                    if ( msg ){
                        location.href = 'main.php?lsaction=setprice';
                    } 
                </script>";
    }
    if ( $highprice < 0 || empty($highprice)){
        echo "<script>var  msg = confirm('最高价格不能为小于0！<br>');
                    if ( msg ){
                        location.href = 'main.php?lsaction=setprice';
                    } 
                </script>";
    }
    if ( $lowerprice < 0 || empty($lowerprice)){
        echo "<script>var  msg = confirm( '最低价格不能为小于0！<br>');
                    if ( msg ){
                        location.href = 'main.php?lsaction=setprice';
                    } 
                </script>";
    }
    if ( $openprice < 0 || empty($openprice)){
        echo "<script>var  msg = confirm('开仓价格不能为小于0！<br>');
                    if ( msg ){
                        location.href = 'main.php?lsaction=setprice';
                    } 
                </script>";
    }
    if ( $closeprice < 0 || empty($closeprice)){
        echo "<script>var  msg = confirm( '关仓价格不能为小于0！');
                    if ( msg ){
                        location.href = 'main.php?lsaction=setprice';
                    } 
                </script>";
    }

    $curtime = time();
	$sql = "insert ld_coin_price (price,highprice,lowerprice,openprice,closeprice ,update_time) 
	values({$price},{$highprice},{$lowerprice},{$openprice},{$closeprice},{$curtime})";
	$db->sitedbexec($sql);
	record_log('修改价格参数'.$uname);
	show_automsg('修改价格成功！',YMCURL.'setprice');
}else{
    $db->query('select * from ld_coin_price order by update_time desc limit 1',2);
    $data = $db->rs;

}


echo '<h3>VIC价格设置</h3>';
echo '<div class="main-r-body"><form method="post" action="'.geturl().'">
		<div class="main-r-item">
		<input type="submit" class="thabtn" value="保存"></div>
		<input type="hidden" name="act" value="add">;
		<input type="hidden" name="id" value="'.$data['id'].'">';
echo '<table class="tregtab ttab">';
echo '<tr>
		<td class="wdb20 alignr paddingr">最新价格</td>
		<td class="alignl paddingl"><input type="text" name="price" value="'.$data['price'].'" class="thconfig wd400"></td>
	  </tr>';
echo '<tr>
		<td class="wdb20 alignr paddingr">最高价格</td>
		<td class="alignl paddingl"><input type="text" name="highprice" value="'.$data['highprice'].'" class="thconfig wd400"></td>
	  </tr>';
echo '<tr>
		<td class="wdb20 alignr paddingr">最低价格</td>
		<td class="alignl paddingl"><input type="text" name="lowerprice" value="'.$data['lowerprice'].'" class="thconfig wd400"></td>
	  </tr>';
echo '<tr>
		<td class="wdb20 alignr paddingr">开仓价格</td>
		<td class="alignl paddingl"><input type="text" name="openprice" value="'.$data['openprice'].'" class="thconfig wd400"></td>
	  </tr>';
echo '<tr>
		<td class="wdb20 alignr paddingr">关仓价格</td>
		<td class="alignl paddingl"><input type="text" name="closeprice" value="'.$data['closeprice'].'" class="thconfig wd400"></td>
	  </tr>';
echo '</table>';
echo '</form></div>';
?>